package com.darrenchan.leetcode;

/**
 * @Desc
 * @Author chenchi03
 * @CreateTime 2019-12-05 00:57
 */
public class Q13 {
    public int romanToInt(String s) {
        int res = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == 'I' && i + 1 < s.length() && s.charAt(i + 1) == 'V') {
                res += 4;
                i++;
                continue;
            }
            if(s.charAt(i) == 'I' && i + 1 < s.length() && s.charAt(i + 1) == 'X') {
                res += 9;
                i++;
                continue;
            }
            if(s.charAt(i) == 'X' && i + 1 < s.length() && s.charAt(i + 1) == 'L') {
                res += 40;
                i++;
                continue;
            }
            if(s.charAt(i) == 'X' && i + 1 < s.length() && s.charAt(i + 1) == 'C') {
                res += 90;
                i++;
                continue;
            }
            if(s.charAt(i) == 'C' && i + 1 < s.length() && s.charAt(i + 1) == 'D') {
                res += 400;
                i++;
                continue;
            }
            if(s.charAt(i) == 'C' && i + 1 < s.length() && s.charAt(i + 1) == 'M') {
                res += 900;
                i++;
                continue;
            }
            if(s.charAt(i) == 'I') res += 1;
            if(s.charAt(i) == 'V') res += 5;
            if(s.charAt(i) == 'X') res += 10;
            if(s.charAt(i) == 'L') res += 50;
            if(s.charAt(i) == 'C') res += 100;
            if(s.charAt(i) == 'D') res += 500;
            if(s.charAt(i) == 'M') res += 1000;
        }
        return res;
    }

    public static void main(String[] args) {
//        System.out.println(new Q13().romanToInt("MCMXCIV"));
        for (int i = 0; i < 10; i++) {
            if(i % 2 == 0){
                System.out.println(i);
                i++;
                continue;
            }
        }
    }
}
